home *** CD-ROM | disk | FTP | other *** search
- (*===========================================================================*)
- (* Edit a file -- Subroutines -- NON overlayed *)
- (* *)
- (* Copyright (c) 1985, 87 by Borland International, Inc. *)
- (* Copyright 1988, 1989, 1991 by H. Roy Engehausen. All rights reserved. *)
- (* *)
- (* This code cannot be used in other programs except in conjunction *)
- (* with a licensed copy of the Turbo Editor Toolbox *)
- (* *)
- (*===========================================================================*)
-
- {$UNDEF DEBUG_OVER}
- {$UNDEF DEBUG_BP}
-
- UNIT BBEDITS;
-
- INTERFACE
-
- USES
- bined;
-
- PROCEDURE usereventcheck(eventno, kbdflaginfo : WORD);
-
- PROCEDURE executeeditor;
-
- (*===========================================================================*)
- (* Constants to control the editor *)
- (*===========================================================================*)
-
- CONST
- myexitcommands :
- ARRAY[0..27] OF CHAR = (#2, ^K, ^Q,
- #2, #0, #68, (* F10 *)
- #2, #0, #38, (* Alt-L *)
- #2, #0, #18, (* Alt-E *)
- #2, #0, #16, (* Alt-Q *)
- #2, #0, #37, (* Alt-K *)
- #2, #0, #19, (* Alt-R *)
- #2, #0, #35, (* Alt-H *)
- #2, #0, #46, (* Alt-C *)
- #0);
- makebackup = FALSE;
-
- (*===========================================================================*)
- (* The main variables *)
- (*===========================================================================*)
-
- VAR
- eddata : EDCB; (* Editor control block *)
- edit_size : LONGINT; (* Size of file *)
- exitcode : WORD; (* Status code set by binary editor functions *)
- exitcomcode : INTEGER; (* Code for command used to leave editor *)
- fname : STRING; (* Input name of file being edited *)
-
- windx : WORD; (* Places to save x and y *)
- windy : WORD;
-
- windx1 : BYTE; (* Places to save x and y *)
- windx2 : BYTE;
- windy1 : BYTE;
- windy2 : BYTE;
-
- TYPE
- borderelements = (topleft, topright, botleft, botright, horiz, vert);
- borderchars = ARRAY[borderelements] OF CHAR;
-
- CONST
- border : borderchars = '┌┐└┘─│';
- noborder : borderchars = ' ';
-
- (*===========================================================================*)
- (* Debugging control *)
- (*===========================================================================*)
-
- IMPLEMENTATION
-
- USES
- DOS,
- CRT,
- bbdummy,
- bbdump,
- bbover,
- bbtask,
- bbwin;
-
- (*===========================================================================*)
- (* User-Event check. Called by editor periodically to allow us to switch *)
- (* Note the user event handler must have a FAR attribute *)
- (*===========================================================================*)
-
- PROCEDURE usereventcheck(eventno, kbdflaginfo : WORD);
-
- VAR
- save_x : BYTE;
- save_y : BYTE;
- wind_max : WORD;
- wind_min : WORD;
-
- BEGIN;
-
- IF NOT active_tcb^.tcb_no_overlay THEN
- BEGIN;
- WRITELN('Event check with overlay enabled');
- dump_string('Event check with overlay enabled');
- dump_trace;
- HALT;
- END;
-
- (*---------------------------------------------------------------------*)
- (* Save current cursor location and window *)
- (*---------------------------------------------------------------------*)
-
- wind_min := WINDMIN;
- wind_max := WINDMAX;
- save_x := WHEREX;
- save_y := WHEREY;
-
- (*---------------------------------------------------------------------*)
- (* Switch tasks *)
- (*---------------------------------------------------------------------*)
-
- task_switch;
-
- (*---------------------------------------------------------------------*)
- (* Restore current cursor location *)
- (*---------------------------------------------------------------------*)
-
- WINDOW(LO(wind_min) + 1,
- HI(wind_min) + 1,
- LO(wind_max) + 1,
- HI(wind_max) + 1);
-
- GOTOXY(save_x, save_y);
-
- END;
-
- PROCEDURE executeeditor;
-
- BEGIN;
-
- overlay_save;
- active_tcb^.tcb_no_overlay := TRUE;
-
- exitcomcode := usebinaryeditor(eddata, '');
-
- active_tcb^.tcb_no_overlay := FALSE;
- overlay_restore;
-
- END;
-
- END.